import express from 'express';
import {
  getClubRegistrations,
  getClubRegistrationById,
  createClubRegistration,
  updateClubRegistration,
  deleteClubRegistration,
  seckillClubRegistration,
  getClubRegistrationsFromCache,
  getClubRegistrationsFromCacheByClubName,
  getClubRegistrationsFromCacheAll

} from '../controllers/clubRegistrationController.js';
import { auth, hasPermission } from '../middleware/auth.js';

const router = express.Router();

// 社团秒杀报名 - 需要create_club_registrations权限
router.post('/seckill',
  // auth, 
  // hasPermission('create_club_registrations'), 
  seckillClubRegistration);

// 从缓存中获取所有社团报名记录 - 需要read_club_registrations权限
router.get('/cache',
  // auth,
  // hasPermission('read_club_registrations'),
  getClubRegistrationsFromCache);

// 从缓存中根据名称获取社团已经报名人数 - 需要read_club_registrations权限
router.get('/cache/clubName',
  // auth,
  // hasPermission('read_club_registrations'),
  getClubRegistrationsFromCacheByClubName);
  
  router.get('/cache/all',
    // auth,
    // hasPermission('read_club_registrations'),
    getClubRegistrationsFromCacheAll);

// 获取所有社团报名记录 - 需要read_club_registrations权限
router.get('/', 
  // auth, 
  // hasPermission('read_club_registrations'), 
  getClubRegistrations);

// 根据ID获取社团报名记录 - 需要read_club_registrations权限
router.get('/:id', 
  // auth, 
  // hasPermission('read_club_registrations'), 
  getClubRegistrationById);

// 创建社团报名记录 - 需要create_club_registrations权限
router.post('/', 
  // auth, 
  // hasPermission('create_club_registrations'), 
  createClubRegistration);

// 更新社团报名记录 - 需要update_club_registrations权限
router.put('/:id', 
  // auth, 
  // hasPermission('update_club_registrations'), 
  updateClubRegistration);

// 删除社团报名记录 - 需要delete_club_registrations权限
router.delete('/:id', 
  auth, 
  hasPermission('delete_club_registrations'), 
  deleteClubRegistration);



export default router;